import java.util.Arrays;
import java.util.List;
import java.util.LinkedList;


public class Node 
{
	private List<Node> enfants;
	private int[] deplacement;
	
	public Node(final int departX, final int departY, final int arriveeX, final int arriveeY)
	{
		this.enfants = new LinkedList<Node>();
		
		this.deplacement = new int[4];
		this.deplacement[0] = departX;
		this.deplacement[1] = departY;
		this.deplacement[2] = arriveeX;
		this.deplacement[3] = arriveeY;
	}
	
	public boolean isLeaf()
	{
		return (this.enfants.size() == 0);
	}

	public List<Node> getEnfants()
	{
		return this.enfants;
	}
	
	public void setEnfants(List<Node> enfants)
	{
		this.enfants = enfants;
	}
	
	public Node getEnfant(Node enfant)
	{
		if (enfant == null) {
			return null;
		}
		
		for (Node n : this.enfants) {
			if (Arrays.equals(n.deplacement, enfant.getDeplacement())) {
				return n;
			}
		}
		
		return null;
	}

	public void ajouterEnfant(Node enfant)
	{
		this.enfants.add(enfant);
	}
	
	public int[] getDeplacement()
	{
		return this.deplacement;
	}
}
